using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;
using NUnit.Framework;
using SCSFContrib.CompositeUI.WPF.Workspaces;

namespace SCSFContrib.CompositeUI.WPF.UnitTest.Workspaces
{
	[TestFixture]
	public sealed class TabSmartPartInfoTest : UnitTest
	{
		private TabSmartPartInfo _tabSmartPartInfo;

		protected override void SetUpCore()
		{
			base.SetUpCore();
			_tabSmartPartInfo = new TabSmartPartInfo();
		}

		[Test]
		public void Constructor_ShouldSetDefaults()
		{
			Assert.AreEqual(string.Empty, _tabSmartPartInfo.Header);
			Assert.AreEqual(TabPosition.End, _tabSmartPartInfo.Position);
			Assert.IsTrue(_tabSmartPartInfo.Activate);
		}

		[Test]
		public void Constructor_Header_ShouldAssignHeader()
		{
			_tabSmartPartInfo = new TabSmartPartInfo("header");
			Assert.AreEqual("header", _tabSmartPartInfo.Header);
		}

		[Test]
		public void Header_ShouldReturnTitleIfNotSet()
		{
			_tabSmartPartInfo.Title = "title";
			Assert.AreEqual("title", _tabSmartPartInfo.Header);
			_tabSmartPartInfo.Header = "header";
			Assert.AreEqual("header", _tabSmartPartInfo.Header);
			_tabSmartPartInfo.Header = null;
			Assert.AreEqual("title", _tabSmartPartInfo.Header);
		}

		[Test]
		public void Properties_ShouldGetAndSetCorrectly()
		{
			object header = new object();
			_tabSmartPartInfo.Header = header;
			_tabSmartPartInfo.Position = TabPosition.End;
			_tabSmartPartInfo.Activate = false;

			Assert.AreSame(header, _tabSmartPartInfo.Header);
			Assert.AreEqual(TabPosition.End, _tabSmartPartInfo.Position);
			Assert.IsFalse(_tabSmartPartInfo.Activate);
		}

		[Test]
		[ExpectedException(typeof(ArgumentNullException))]
		public void ApplyTo_TabItem_ShouldThrowIfWindowIsNull()
		{
			_tabSmartPartInfo.ApplyTo((TabItem) null);
		}

		[Test]
		public void ApplyTo_TabItem_ShouldApplyPropertiesToGivenTabItem()
		{
			TabItem tabItem = new TabItem();
			_tabSmartPartInfo.Header = "header";
			_tabSmartPartInfo.ApplyTo(tabItem);
			Assert.AreEqual("header", tabItem.Header);
		}

		[Test]
		[ExpectedException(typeof(ArgumentNullException))]
		public void ApplyTo_TabSmartPartInfo_ShouldThrowIfTabSmartPartInfoIsNull()
		{
			_tabSmartPartInfo.ApplyTo((TabSmartPartInfo) null);
		}

		[Test]
		public void ApplyTo_TabSmartPartInfo_ShouldApplyPropertiesToGivenTabSmartPartInfo()
		{
			TabSmartPartInfo destination = new TabSmartPartInfo();

			_tabSmartPartInfo.Header = "header";
			_tabSmartPartInfo.Position = TabPosition.End;
			_tabSmartPartInfo.Activate = false;

			_tabSmartPartInfo.ApplyTo(destination);

			Assert.AreEqual("header", destination.Header);
			Assert.AreEqual(TabPosition.End, destination.Position);
			Assert.IsFalse(destination.Activate);
		}
	}
}